package org.gulugulubiao.controller;

import lombok.extern.slf4j.Slf4j;
import org.gulugulubiao.result.Result;
import org.gulugulubiao.service.AnsRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("ansRecord")
@Slf4j
public class AnsRecordController {
    @Autowired
    private AnsRecordService ansRecordService;

    /**
     * 更新答题记录
     * @param problemId
     * @param status
     * @return
     */
    @PutMapping("/update/{problemId}")
    public Result updateUserAnsRecord(@PathVariable Integer problemId, @RequestBody Integer status,@RequestBody Integer userId){
        log.info("题目id:{}，状态为:{}",problemId,status);
        //拼接为当前用户答题记录表
        String ansRecordTableName = userId + "_user";
        ansRecordService.update(problemId,status,ansRecordTableName);
        return Result.success("成功更新答题记录表！");
    }
}
